package com.inspur.edp.bff.spi.assembler;

import com.inspur.edp.bff.api.manager.IFSManagerContext;
import com.inspur.edp.bff.api.manager.assembler.IExtendCancelAssember;
import com.inspur.edp.bff.api.manager.context.CancelContext;
import com.inspur.edp.bff.spi.action.cancel.AbstractCancelAction;
import com.inspur.edp.bff.spi.action.cancel.DefaultCancelAction;

import java.util.ArrayList;

public abstract class AbstractExtendCancelAssember implements IExtendCancelAssember {


    protected ArrayList<AbstractCancelAction> getCancelActions(CancelContext delContext) {
        return null;
    }

    @Override
    public void doCancel(IFSManagerContext context, CancelContext cancelContext) {
        ArrayList<AbstractCancelAction> cancelActions = getCancelActions(cancelContext);
        if (cancelActions == null || cancelActions.size() == 0) {
            DefaultCancelAction cancelAction = new DefaultCancelAction(cancelContext);
            cancelAction.deal(context);
        } else {
            for (AbstractCancelAction action : getCancelActions(cancelContext)) {
                action.deal(context);
            }
        }

    }
}
